home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / tsipp / tsipp.lha / tsipp3.0a / src / tSippInt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-02  |  9.4 KB  |  295 lines

  1. /*
  2.  *=============================================================================
  3.  *                                tSippInt.h
  4.  *-----------------------------------------------------------------------------
  5.  * Internal, global declarations for Tcl SIPP interface.
  6.  *-----------------------------------------------------------------------------
  7.  * Copyright 1992 Mark Diekhans
  8.  * Permission to use, copy, modify, and distribute this software and its
  9.  * documentation for any purpose and without fee is hereby granted, provided
  10.  * that the above copyright notice appear in all copies.  Mark Diekhans makes
  11.  * no representations about the suitability of this software for any purpose.
  12.  * It is provided "as is" without express or implied warranty.
  13.  *-----------------------------------------------------------------------------
  14.  * $Id: tSippInt.h,v 2.0 1992/11/02 03:56:16 markd Rel $
  15.  *=============================================================================
  16.  */
  17.  
  18. #include <malloc.h>
  19. #include <stdio.h>
  20. #include <math.h>
  21. #include <string.h>
  22. #include <memory.h>
  23.  
  24. #include "tclExtend.h"
  25. #include "sipp.h"
  26. #include "shaders.h"
  27. #include "primitives.h"
  28.  
  29. /*
  30.  * Version suffix for tsipp.  It is append to the SIPP version to identify
  31.  * the version number for tsipp.  Also a variable that will contain the
  32.  * full version string, including patch level.
  33.  */
  34. #define TSIPP_VERSION_SUFFIX "a"
  35.  
  36. extern char *TSIPP_VERSION;
  37.  
  38. /*
  39.  * Global Tcl SIPP structure.  It is the client data to all commands.
  40.  */
  41.  
  42. typedef struct {
  43.     Tcl_Interp    *interp;           /* Tcl interpreter pointer.             */
  44.     bool           showBackFaces;    /* Render or draw backfaceing polys.    */
  45.     Color          backgroundColor;  /* Current background color.            */
  46.     Color          lineColor;        /* Color for lines in RLE LINE render   */
  47.     void_pt        surfaceTblPtr;    /* Surface table.                       */
  48.     void_pt        objectTblPtr;     /* Object table.                        */
  49.     void_pt        shaderTblPtr;     /* Shader table.                        */
  50.     void_pt        lightTblPtr;      /* Light table.                         */
  51.     void_pt        cameraTblPtr;     /* Camera table.                        */
  52.     void_pt        rleTblPtr;        /* RLE file table.                      */
  53. } tSippGlob_t, *tSippGlob_pt;
  54.  
  55. /*
  56.  * Type used to pass parser rendering parameters.
  57.  */
  58. typedef struct {
  59.     char     *fileHandle;            /* Ptr to file handle in argv.          */
  60.     unsigned  xSize;                 /* Size of image to render.             */
  61.     unsigned  ySize;
  62.     unsigned  mode;                  /* FLAG, GOURAUD, PHONG or LINE.        */
  63.     unsigned  overSampling;          /* Oversampling factor.                 */
  64.     bool      interlaced;            /* Interlaced (field) rendering.        */
  65.     int       field;                 /* ODD or EVEN scan lines.              */
  66. } tSippRenderParms_t, *tSippRenderParms_pt;
  67.  
  68. /*
  69.  * Type used in initializing Tcl commands.
  70.  */
  71. typedef struct {
  72.     char        *name;
  73.     Tcl_CmdProc *proc;
  74. } tSippTclCmdTbl_t;
  75.  
  76. /*
  77.  * Type used to store a translated handle list.  A static array is used
  78.  * unless the list is bigger, then it goes dynamic.
  79.  */
  80. #define HANDLE_LIST_STATIC_SIZE 16
  81.  
  82. typedef struct {
  83.     void   **ptr;
  84.     int      len;
  85.     void    *staticArray [HANDLE_LIST_STATIC_SIZE];
  86. } handleList_t, *handleList_pt;
  87.  
  88. /*
  89.  * Macros to do string compares.  They pre-check the first character before
  90.  * checking of the strings are equal.
  91.  */
  92.  
  93. #define STREQU(str1, str2) \
  94.         (((str1) [0] == (str2) [0]) && (strcmp (str1, str2) == 0))
  95. #define STRNEQU(str1, str2, cnt) \
  96.         (((str1) [0] == (str2) [0]) && (strncmp (str1, str2, cnt) == 0))
  97.  
  98. /*
  99.  * Macros to handle dealing with numbers that may have encountered a round
  100.  * off error:
  101.  *   FZERO - Is the number zero, with in the tolerance.
  102.  *   FZERO_ROUND - Round the number to zero, if its in the tolerance of zero.
  103.  *   FEQUAL - Is the number equal, within the tolerance.
  104.  *
  105.  */
  106. #define TOLERANCE 1e-13
  107. #define FZERO(f) ((f) < TOLERANCE && (f) > -TOLERANCE)
  108. #define FZERO_ROUND(f) (FZERO(f) ? 0.0 : (f))
  109. #define FEQUAL(f1, f2) ((((f2) - TOLERANCE) < (f1)) && \
  110.                         ((f1) < (((f2) + TOLERANCE))))
  111.  
  112. /*
  113.  * WARNING: This is an internal Tcl data structure and function.  It might
  114.  * change.  John needs to export this fucntion.
  115.  */
  116. typedef struct OpenFile {
  117.     FILE *f;
  118.     FILE *f2;
  119.     int readable;
  120.     int writable;
  121.     int numPids;
  122.     int *pidPtr;
  123.     int errorId;
  124. } OpenFile;
  125.  
  126. extern int
  127. TclGetOpenFile _ANSI_ARGS_((Tcl_Interp  *interp,
  128.                             char        *string, 
  129.                             OpenFile   **filePtrPtr));
  130.  
  131.  
  132. /*
  133.  * tSippUtil.c externals.
  134.  */
  135. bool
  136. TSippConvertFraction _ANSI_ARGS_((tSippGlob_pt  tSippGlobPtr,
  137.                                   char         *strBuf,
  138.                                   double       *valuePtr));
  139.  
  140. bool
  141. TSippConvertUnsignedDbl _ANSI_ARGS_((tSippGlob_pt  tSippGlobPtr,
  142.                                      char         *strBuf,
  143.                                      double       *valuePtr));
  144.  
  145. bool
  146. TSippConverPosUnsigned _ANSI_ARGS_((tSippGlob_pt  tSippGlobPtr,
  147.                                     char         *strBuf,
  148.                                     unsigned     *valuePtr));
  149.  
  150. bool
  151. TSippConvertColor _ANSI_ARGS_((tSippGlob_pt  tSippGlobPtr,
  152.                                char         *listStr,
  153.                                Color        *colorPtr));
  154.  
  155. bool
  156. TSippConvertOpacity _ANSI_ARGS_((tSippGlob_pt  tSippGlobPtr,
  157.                                  char         *listStr,
  158.                                  Color        *opacityPtr));
  159.  
  160. bool
  161. TSippConvertAngleRad _ANSI_ARGS_((tSippGlob_pt  tSippGlobPtr,
  162.                                   char         *strBuf,
  163.                                   double       *valuePtr));
  164.  
  165. bool
  166. TSippConvertAngleDeg _ANSI_ARGS_((tSippGlob_pt  tSippGlobPtr,
  167.                                   char         *strBuf,
  168.                                   double       *valuePtr));
  169.  
  170. bool
  171. TSippConvert2DPoint _ANSI_ARGS_((tSippGlob_pt  tSippGlobPtr,
  172.                                  char         *listStr,
  173.                                  double       *xCoordPtr,
  174.                                  double       *yCoordPtr));
  175.  
  176. bool
  177. TSippConvertVertex _ANSI_ARGS_((tSippGlob_pt  tSippGlobPtr,
  178.                                 char         *listStr,
  179.                                 Vector       *vertexPtr));
  180.  
  181. bool
  182. TSippConvertVertexTex _ANSI_ARGS_((tSippGlob_pt  tSippGlobPtr,
  183.                                    char         *listStr,
  184.                                    Vector       *vertexPtr,
  185.                                    Vector       *texturePtr));
  186.  
  187. bool
  188. TSippConvertMatrix _ANSI_ARGS_((tSippGlob_pt  tSippGlobPtr,
  189.                                 char         *listStr,
  190.                                 Transf_mat   *matrixPtr));
  191.  
  192. char *
  193. TSippFormatMatrix _ANSI_ARGS_((Transf_mat   *matrixPtr));
  194.  
  195. bool
  196. TSippHandleListConvert _ANSI_ARGS_((tSippGlob_pt   tSippGlobPtr,
  197.                                     void          *handleTblPtr,
  198.                                     char          *listPtr,
  199.                                     handleList_pt  handleListPtr,
  200.                                     handleList_pt  handleEntryListPtr));
  201.  
  202. void
  203. TSippHandleListFree _ANSI_ARGS_((handleList_pt  handleListPtr));
  204.  
  205. void
  206. TSippInitCmds _ANSI_ARGS_((tSippGlob_pt       tSippGlobPtr,
  207.                            tSippTclCmdTbl_t  *cmdTablePtr));
  208.  
  209. bool
  210. TSippParseRenderParms _ANSI_ARGS_((tSippGlob_pt         tSippGlobPtr,
  211.                                    int                  argc,
  212.                                    char               **argv,
  213.                                    char                *fileTitle,
  214.                                    tSippRenderParms_pt  renderParmsPtr));
  215.  
  216. bool
  217. TSippParseTextureMapping _ANSI_ARGS_((tSippGlob_pt    tSippGlobPtr,
  218.                                       char           *textureStr,
  219.                                       int            *texturePtr,
  220.                                       int            *invalidList));
  221.  
  222. void
  223. TSippInitialize _ANSI_ARGS_((Tcl_Interp *interp));
  224.  
  225. /*
  226.  * tSippBezier.c externals.
  227.  */
  228. void
  229. TSippBezierInit _ANSI_ARGS_((tSippGlob_pt  tSippGlobPtr));
  230.  
  231. /*
  232.  * tSippPoly.c externals.
  233.  */
  234. Surface *
  235. TSippSurfaceHandleToPtr _ANSI_ARGS_((tSippGlob_pt    tSippGlobPtr,
  236.                                      char           *handle));
  237.  
  238. void
  239. TSippPolyInit _ANSI_ARGS_((tSippGlob_pt  tSippGlobPtr));
  240.  
  241. /*
  242.  * tSippObj.c externals.
  243.  */
  244. void
  245. TSippBindObjectToHandle _ANSI_ARGS_((tSippGlob_pt    tSippGlobPtr,
  246.                                     Object         *objectPtr));
  247.  
  248. Object *
  249. TSippObjectHandleToPtr _ANSI_ARGS_((tSippGlob_pt    tSippGlobPtr,
  250.                                     char           *handle));
  251.  
  252. void
  253. TSippObjectInit _ANSI_ARGS_((tSippGlob_pt tclSippGlobP));
  254.  
  255. /*
  256.  * tSippLight.c externals.
  257.  */
  258. void
  259. TSippLightInit _ANSI_ARGS_((tSippGlob_pt    tSippGlobPtr));
  260.  
  261. /*
  262.  * tSippCamera.c externals.
  263.  */
  264. void
  265. TSippCameraInit _ANSI_ARGS_((tSippGlob_pt  tSippGlobPtr));
  266.  
  267. /*
  268.  * tSippShader.c externals.
  269.  */
  270. Shader *
  271. TSippShaderHandleToPtr _ANSI_ARGS_((tSippGlob_pt    tSippGlobPtr,
  272.                                     char           *handle,
  273.                                     void          **surfDescPtrPtr));
  274.  
  275. void
  276. TSippShaderInit _ANSI_ARGS_((tSippGlob_pt  tclSippGlobP));
  277.  
  278. /*
  279.  * tSippPrim.c externals.
  280.  */
  281. void
  282. TSippPrimInit _ANSI_ARGS_((tSippGlob_pt  tSippGlobPtr));
  283.  
  284. /*
  285.  * tSippPPM.c  externals.
  286.  */
  287. void
  288. TSippPPMInit _ANSI_ARGS_((tSippGlob_pt    tSippGlobPtr));
  289.  
  290. /*
  291.  * tSippRLE.c  externals.
  292.  */
  293. void
  294. TSipp_RLEInit _ANSI_ARGS_((tSippGlob_pt    tSippGlobPtr));
  295.